package com.diqye.templet.method;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.diqye.templet.core.Method;
/**
 * 根据大括号格式化字符串
 *
 * @author 秦振龙
 * @date 2013-7-8
 *
 * <b>修改记录及说明：</b>
 * <ul>
 * <li>2013-7-8  秦振龙  创建</li>
 * </ul>
 */
public class MapBraceMethodForSql implements Method {
	@SuppressWarnings("rawtypes")
	private  Map objectMap;
	private int start = 1;
	private List<Object> params = new ArrayList<Object>();
	@SuppressWarnings("rawtypes")
	public MapBraceMethodForSql(Map objectMap ,int start){
		this(objectMap);
		this.start = start;
	}
	@SuppressWarnings("rawtypes")
	public MapBraceMethodForSql(Map objectMap){
		this.objectMap = objectMap;
	}
	
	public String invok(String str) {
		String rstr = str.substring(start,str.length()-1);
		Object o = objectMap.get(rstr);
		/*if(o == null){
			return str;
		}*/
		params.add(o);
		return "?";
	}
	public List<Object> getParams() {
		return params;
	}
	
}
